package com.mc.moring.util.ext

import android.view.View
import com.mc.moring.R

object ViewExt {

    inline fun View?.extClickLimit(time: Long = 500, crossinline runnable: (View) -> Unit) {
        this?.setOnClickListener {
            val lastTime = (getTag(R.id.view_click_limit) as? Long) ?: 0
            if (System.currentTimeMillis() - lastTime >= time) {
                runnable.invoke(this)
                setTag(R.id.view_click_limit, System.currentTimeMillis())
            }
        }
    }

}